package com.back.controller;


import com.back.service.PayService;
import com.back.service.context.PayContext;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;


// https://blog.csdn.net/weixin_52536274/article/details/135583318
@Controller
@RequestMapping("/money")
public class PayController {


    @Resource
    private PayContext payService;

    @GetMapping("/pay")
    public void pay(HttpServletResponse httpServletResponse) throws IOException {
        String payService1 = payService.getPayService(1);
        httpServletResponse.setContentType("text/html;charset=UTF-8");
        PrintWriter writer = httpServletResponse.getWriter();
        writer.print(payService1);
        httpServletResponse.getWriter().flush();
        httpServletResponse.getWriter().close();

    }

    @GetMapping("/query")
    @ResponseBody
    public String query(HttpServletResponse httpServletResponse) throws IOException {
        String payService1 = payService.query(1);
        return payService1;
    }
}
